import request from '../utils/request.js'
import {
	getUid
} from '../utils/auth.js'
let getId = getUid()
export default {
	login(username, password, type) {
		return request({
			url: '/users/login',
			method: 'post',
			data: {
				username,
				password,
				type
			}
		})
	},
	//发布通知接口 
	announce(title, classes) {
		return request({
			url: '/admin/announce',
			method: 'post',
			data: {
				title,
				classes
			}
		})
	},
	//获取所有通知带分页
	getAllNotice(pageNum, currPage) {
		return request({

			url: '/admin/getAllNotice/' + currPage + '/' + pageNum,
			method: 'get',
			params: {

			}
		})
	},

	//提交健康报表
	health(datas) {
		return request({
			url: '/students/sethealth',
			method: 'post',
			data: {
				...datas
			}
		})
	},
	//获取当天某用户报表
	getHealthNowDayByid(uId) {
		uId = uId ? uId : getId
		return request({
			url: '/students/getHealthNowDayByid/' + uId,
			method: 'get',

		})
	},
	//获取当天某所有报表
	gethealthNowDay() {
		return request({
			url: '/students/gethealthNowDay',
			method: 'get',

		})
	},
	//获取用户个人信息
	getUserDataById(id) {
		id = id ? id : getId
		return request({
			url: '/users/getUserDataById/' + id,
			method: 'get',

		})
	},
	//我的通知分页获取数据与数量
	getNotice(id, currPage, pageNum) {
		id = id ? id : getId
		return request({
			url: '/students/getNotice/' + id + '/' + currPage + '/' + pageNum,
			method: 'get',

		})
	},
	//请假申请
	setLeave(endtime, leavetype, reason, starttime, uId) {
		uId = uId ? uId : getId
		return request({
			url: '/students/setLeave',
			method: 'post',
			data: {
				endtime: endtime,
				leavetype: leavetype,
				reason: reason,
				starttime: starttime,
				uId: uId
			}
		})
	},
	//老师获取所有请假单
	getLeave(currPage, pageNum, uId) {
		uId = uId ? uId : getId
		return request({
			url: '/admin/getLeave/' + uId + '/' + currPage + '/' + pageNum,
			method: 'get',

		})
	},
	//学生获取个人请假单列表
	getUserLeave(currPage, pageNum, uId) {
		uId = uId ? uId : getId
		return request({
			url: '/admin/getUserLeave/' + uId + '/' + currPage + '/' + pageNum,
			method: 'get',

		})
	},
	//老师审批请假单
	upLeaveState(lid, upState) {
		return request({
			url: '/admin/upLeaveState/' + lid + '/' + upState,
			method: 'get',

		})
	},
	//修改个人密码
	upPwd(newpassword, oldpassword, uId) {
		uId = uId ? uId : getId
		return request({
			url: '/users/upPwd',
			method: 'post',
			data: {
				newpassword: newpassword,
				oldpassword: oldpassword,
				uid: uId
			}
		})
	},
	//用户头像修改
	upicon(url, uId) {
		uId = uId ? uId : getId
		return request({
			url: '/users/upicon/' + uId,
			method: 'get',
			params: {
				url: url
			}
		})
	},
	//删除通知
	delNotice(id) {
		return request({
			url: '/admin/delNotice/' + id,
			method: 'delete',
			params: {

			}
		})
	},
	//查询班级列表
	getClassesSear(inputText, currPage, pageNum) {
		return request({
			url: '/admin/getClassesSear/' + inputText + '/' + currPage + '/' + pageNum,
			method: 'get',
			params: {

			}
		})
	},
	//班级列表
	getClasses() {
		return request({
			url: '/admin/getClasses',
			method: 'get',
			params: {

			}
		})
	},
	//根据用户类型进行用户信息获取(分页获取总数量与数据)
	getUsersByTypePage(type, currPage, pageNum) {
		return request({
			url: '/users/getUsersByTypePage/' + type + '/' + currPage + '/' + pageNum,
			method: 'get',
			params: {

			}
		})
	},
	//获取当月所有填报表
	gethealthNowMonth() {
		return request({
			url: '/students/gethealthNowMonth',
			method: 'get',
			params: {

			}
		})
	},
	//获取当天所有填报表
	gethealthNowDay() {
		return request({
			url: '/students/gethealthNowDay',
			method: 'get',
			params: {

			}
		})
	},
	//所有用户信息获取
	getUserDataByToken(token) {
		return request({
			url: '/admin/getUserDataByToken/' + token,
			method: 'get',
			params: {

			}
		})
	},
	//获取的我通知已读列表(供已读未读状态渲染
	getNoticeRead() {
		return request({
			url: '/students/getNoticeRead/' + getId,
			method: 'get',
			params: {

			}
		})
	},
	//退出登录
	logout() {
		return request({
			url: '/users/logout',
			method: 'get',
			params: {

			}
		})
	},
	//根据用户类型与查询字段模糊查询 (数据与总数量返回)
	getUsersByTypeAndChar(query) {
		return request({
			url: '/admin/getUsersByTypeAndChar',
			method: 'get',
			params: query
		})
	},
	//删除tb_user信息
	delUserdata(uId) {
		return request({
			url: '/users/delUserdata/' + uId,
			method: 'get',
			params: {

			}
		})
	},
	//用户修改
	upUserdata(data) {
		return request({
			url: '/users/upUserdata',
			method: 'post',
			data: data
		})
	},
	//批量导入用户
	saveByExcel(data) {
		return request({
			url: '/users/saveByExcel',
			method: 'post',
			data: data
		})
	},
	//新增tb_classes信息
	addClasses(classes) {
		return request({
			url: '/admin/addClasses/'+classes,
			method: 'GET',
			params: {}
		})
	},
	//新增tb_classes信息
	getClassesSear(inputText,currPage,pageNum) {
		return request({
			url: '/admin/getClassesSear/'+inputText+'/'+currPage+'/'+pageNum,
			method: 'GET',
			params: {}
		})
	},
	//新增tb_classes信息
	getClasses() {
		return request({
			url: '/admin/getClasses',
			method: 'GET',
			params: {}
		})
	},
	//当前公告查看详情
	NoticeDetails(nId) {
		return request({
			url: '/admin/NoticeDetails/'+nId,
			method: 'GET',
			params: {}
		})
	},
	goyidu(nId,uId) {
		uId = uId ? uId : getId
		return request({
			url: '/students/goyidu/'+nId +'/'+uId,
			method: 'GET',
			params: {}
		})
	},
}
